package com.bishe.psy.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Repository;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * Created with Intellij IDEA.
 * Description:
 * User: L
 * Date: 2024-04-10
 * Time: 10:27
 */

@Configuration
public class AppInterceptorConfig implements WebMvcConfigurer {

    @Resource
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
       registry.addInterceptor(loginInterceptor)         //添加登录拦截器
               .addPathPatterns("/**")                   //拦截所有路径下的请求
               .excludePathPatterns("/sign-in.html")     //排除登录页面
               .excludePathPatterns("/sign-up.html")     //排除注册页面
               .excludePathPatterns("/stu/login")        //排除学生登录接口
               .excludePathPatterns("/con/login")        //排除咨询师录接口
               .excludePathPatterns("/adm/login")        //排除管理员登录接口
               .excludePathPatterns("/stu/register")     //排除学生注册接口
               .excludePathPatterns("/stu/logout")       //排除学生退出接口
               .excludePathPatterns("/con/logout")       //排除咨询师退出接口
               .excludePathPatterns("/adm/logout")       //排除管理员接口
               .excludePathPatterns("/swagger*/**")      //排除swagger测试接口
               .excludePathPatterns("/v3*/**")           //排除v3下与swagger有关
               .excludePathPatterns("/js/**")            //排除所有的静态文件
               .excludePathPatterns("/dist/**")
               .excludePathPatterns("/image/**");

    }
}
